package upm.pb4agent.team8.Common;

import upm.pb4agent.common.Constant;
import upm.pb4agent.ontology.SubscribeReferee;
import upm.pb4agent.team8.Manager.RowerMgr;
import jade.core.AID;
import jade.core.Agent;
import jade.core.behaviours.SimpleBehaviour;
import jade.lang.acl.ACLMessage;

public class SubscribeAgentBehaviour extends SimpleBehaviour
{
	private Agent _agent;
	private boolean _finished = false;
	
	public SubscribeAgentBehaviour(Agent agent)
	{
		super(agent);
		_agent=agent;
	}
	
	@Override
	public void action() 
	{
		AID refereeID = PB4Utils.TryFindAgent(myAgent, Constant.REFEREE);
		if (refereeID != null) 
		{
			SubscribeReferee subscribe = new SubscribeReferee();
			PB4Utils.TrySendConceptMessage(ACLMessage.SUBSCRIBE, _agent, refereeID, subscribe);	
			_finished = true;
		}
	}
	
	@Override
	public boolean done() {
		return _finished;
	}
}
